﻿using System;
using NUnit.Framework;
using Xtensive.Orm;
using Xtensive.Orm.Configuration;

namespace SessionBoundService
{
  public class Program
  {
    [Test]
    public static void Main()
    {
      // Loading domain configuration section with name "Default".
      var domainConfiguration = DomainConfiguration.Load("Default");
      var domain = Domain.Build(domainConfiguration);

      // Accessing session service
      using (var session = domain.OpenSession()) {
        var sessionService = session.Services.Get<IMySessionService>();
        Assert.IsNotNull(sessionService);
        Assert.IsNotNull(sessionService.Session);
        Assert.AreSame(session, sessionService.Session);
        Console.WriteLine("Successfully obtained IMySessionService through Session.Services");
      }
    }
  }
}
